package algorithm;

import java.util.*;
// 逆波兰表达式的构建
public class calculatorExpression {
    private static Stack<String> expression = new Stack<>();
    private static Stack<String> symbol = new Stack<>();
    private static HashMap<String, Integer> priorty = new HashMap<>();
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String line = input.nextLine();

        priorty.put("+", 0);
        priorty.put("-", 0);
        priorty.put("*", 1);
        priorty.put("/", 1);

        for(int i = 0; i < line.length(); i ++) {
            if(line.charAt(i) >= '0' && line.charAt(i) <= '9'){
                int point = i + 1;
                while(point < line.length() && line.charAt(point) >= '0' && line.charAt(point) <= '9') point++;
                expression.push(line.substring(i, point));
                i = point - 1;
            }else{
                if(line.charAt(i) == '(' || symbol.isEmpty())  symbol.push(Character.toString(line.charAt(i)));
                else if(line.charAt(i) == ')') {
                    String temp = symbol.peek();
                    while(!temp.equals("(")){
                        expression.push(temp);
                        temp = symbol.pop();

                    }
                }else {
                    String temp = Character.toString(line.charAt(i));
                    String op = symbol.peek();
                    if(symbol.peek().equals("(")) symbol.push(temp);
                    else {
                        while(priorty.get(op) >= priorty.get(temp)){
                            expression.push(op);
                            symbol.pop();
                            if(symbol.isEmpty()) break;
                            op = symbol.peek();
                        }
                        if(priorty.get(op) < priorty.get(temp)) {
                            symbol.push(temp);
                        }
                    }
                }
            }
        }

        while(!symbol.isEmpty()){
            String temp = symbol.pop();
            expression.push(temp);
        }

        System.out.printf("%s\n", expression.toString());
    }
}
